// @ts-ignore
import Message from 'tdesign-miniprogram/message/index'
import { getPosterList } from '../../http/api/posterService'
import Toast from 'tdesign-miniprogram/toast/index'

Page({
    data: {
        swiperList: []
    },
    getCouponLength() {},

    toOther() {
        Toast({
            context: this,
            selector: '#t-toast',
            message: '请移步至萌云送宠公众号'
        })
    },
    async getPostList() {
        const res: any = await getPosterList()
        console.log(res.data, '---getPostList')
        this.setData({
            swiperList: res.data.map((item: any) => {
                return {
                    value: item.pic_url,
                    ariaLabel: item.ID
                }
            })
        })
    },
    toPreferentialCenter() {
        wx.navigateTo({
            url: '/pages/my/preferentialCenter/preferentialCenter?type=0'
        })
    },
    toDetail(e: any) {
        const path = e.currentTarget.dataset.path
        if (path === 'taxi') {
            wx.navigateTo({ url: '/pages/index/taxi/taxi' })
        } else {
            // @ts-ignore
            Message.info({
                context: this,
                offset: [20, 32],
                duration: 5000,
                content: '敬请期待~~~'
            })
        }
    },
    onShow() {
        this.getPostList()
    },
    onLoad() {
        this.getPostList()
        const type = wx.getStorageSync('user-type')
        if (type == 2) {
            wx.switchTab({
                url: '/pages/driver/index/index'
            })
        }
    }
})
